home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
dflat_r_.arc
/
LOG.C
< prev
next >
Wrap
Text File
|
1991-10-02
|
2KB
|
80 lines
/* ------------ log .c ------------ */
#include <stdio.h>
#include "dflat.h"
#ifdef INCLUDE_LOGGING
#ifndef INCLUDE_HELP
char *ClassNames[] = {
#undef ClassDef
#define ClassDef(c,b,p,a) #c,
#include "classes.h"
NULL
};
#endif
static char *message[] = {
#undef DFlatMsg
#define DFlatMsg(m) " " #m,
#include "dflatmsg.h"
NULL
};
static FILE *log = NULL;
extern DBOX Log;
void LogMessages (WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
{
if (log != NULL && message[msg][0] != ' ')
fprintf(log, "%-20.20s %-12.12s %-20.20s, %5.5ld, %5.5ld\n",
wnd ? (GetTitle(wnd) ? GetTitle(wnd) : "") : "",
wnd ? ClassNames[GetClass(wnd)] : "",
message[msg]+1, p1, p2);
}
static int LogProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
{
WINDOW cwnd = ControlWindow(&Log, ID_LOGLIST);
char **mn = message;
switch (msg) {
case INITIATE_DIALOG:
AddAttribute(cwnd, MULTILINE | VSCROLLBAR);
while (*mn) {
SendMessage(cwnd, ADDTEXT, (PARAM) (*mn), 0);
mn++;
}
SendMessage(cwnd, SHOW_WINDOW, 0, 0);
break;
case COMMAND:
if ((int) p1 == ID_OK) {
int i;
for (i = 0; mn[i] != NULL; i++) {
char *cp = TextLine(cwnd, i);
mn[i][0] = *cp;
}
}
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
void MessageLog(WINDOW wnd)
{
if (DialogBox(wnd, &Log, TRUE, LogProc)) {
if (CheckBoxSetting(&Log, ID_LOGGING))
log = fopen("DFLAT.LOG", "wt");
else if (log != NULL) {
fclose(log);
log = NULL;
}
}
}
#endif